package com.netease.musicweekly.android.adapter;

import java.util.ArrayList;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.netease.musicweekly.android.R;
import com.netease.musicweekly.android.widget.ArticleWebView;

public class ArticleAdapter<T> extends BaseAdapter {

	private ArrayList<T> mArticleArray;

	@Override
	public int getCount() {
		if (null == mArticleArray) {
			return 0;
		}
		return mArticleArray.size();
	}

	@Override
	public T getItem(int position) {
		if (this.mArticleArray != null)
			return mArticleArray.get(position);
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0L;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (null == convertView) {
			ArticleWebView aView = (ArticleWebView) ((LayoutInflater) parent
					.getContext().getSystemService("layout_inflater")).inflate(
					R.layout.article_webview, null);
			if (null != aView) {
				aView.loadUrl("file:///android_asset/model.html");
				return aView;
			}
		}
		return convertView;
	}

}
